﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;

namespace DawnOfConquest
{
    public abstract class Piece
    {
        protected int actionPoints;
        protected int stamina;
        protected int strength;
        protected int dex;
        protected int intel;
        protected int will;
        protected int health;
        protected int damage;
        protected int range;
        protected int level;
        protected int xCoor;
        protected int yCoor;
        protected String faction;

        protected string name;
        protected string terrain;
        protected int xp;
        protected Boolean hasMoved = false;
        protected Boolean hasAttacked = false;
       // protected Tile location;

        protected List<Ability> abilityList = new List<Ability>();
       // public List<Tile> validMoves;

        protected Texture2D spriter;
        protected Texture2D spriteb;

        public Texture2D getSprite()
        {
            if(faction.Equals("BLUE"))
                return spriteb;
            else
                return spriter;
        }

        /*
        public void findValidMoves(Tile[][] map)
        {
            validMoves = new List<Tile>();
            findMoves(location, actionPoints, map);
        }
          */

        public Boolean turnOver()
        {
            return hasMoved;
        }

        public void promptAbility()
        {

        }

        public Boolean hasPieceMoved()
        { return hasMoved; }

        public Boolean hasPieceAttacked()
        { return hasAttacked; }
        public void resetUnit()
        {
            hasMoved = false;
            hasAttacked = false;
        }

        //public string getClass()
        //{

        //}

        public int getAP()
        {
            return actionPoints;
        }

        public void setTerrain(String terrain)
        {
            this.terrain = terrain;
        }

        public String getTerrain()
        {
            return terrain;
        }

        public int getXPosition()
        {
            return xCoor;
        }

        public int getYPosition()
        {
            return yCoor;
        }

        public void move()
        { hasMoved = true; }

        public void attack()
        { hasAttacked = true; }

        public int getStrength()
        {
            return strength;
        }

        public int getDexterity()
        {
            return dex;
        }

        public int getStamina()
        {
            return stamina;
        }

        public int getIntelligence()
        {
            return intel;
        }

        public int getWillpower()
        {
            return will;
        }

        public int getRange()
        {
            return range;
        }

        public int getLevel()
        { return level; }
        public int getXP()
        { return xp; }

        public void addXP(int exp)
        {
            xp += exp;
            if (xp >= maxXP())
            {
                xp = xp - maxXP();
                levelUp();
            }
        }

        public abstract int maxXP();

        public abstract int getAttack();

        public abstract int getDefense();

        public abstract int getDamage();

        public int getHealth()
        {
            return health;
        }

        public string getName()
        {
            return name;
        }

        public void applyDamage(int damage)
        {
            health = health - damage;
        }

        public abstract void levelUp();

        public List<Ability> getAbilities()
        {
          return abilityList;
        }

        public void addStrength(int str)
        {
            strength = strength + str;
        }

        public void addDexterity(int dex)
        {
            this.dex = this.dex + dex;
        }

        public void addStamina(int sta)
        {
            stamina = stamina + sta;
        }

        public void addIntelligence(int intel)
        {
            this.intel = this.intel + intel;
        }

        public void addWillpower(int will)
        {
            this.will = this.will + will;
        }

        public void addActionPoints(int ap)
        {
            actionPoints = actionPoints + ap;
        }

        public void addDamage(int dam)
        {
            damage = damage + dam;
        }

        public String getFaction()
        {
            return faction;
        }

        public void setPosition(int x, int y)
        {
            xCoor = x;
            yCoor = y;
        }
    }
}
